home *** CD-ROM | disk | FTP | other *** search
/ New Masters of Flash / New Masters of Flash.iso / pc / MOVIES / 05.dir / 00222_Text_text17.txt < prev    next >
Text File  |  2000-10-01  |  7KB  |  62 lines

  1. Frame 8: 
  2. (label Refresh 3d View) Moving the Object Around in the World
  3.  
  4. The script contained in this frame refreshes the coordinates of the points in the 3D view when one of the dragable points in the editing view is being dragged.
  5.  
  6. Each of the draggable points contain a button which gives variable:"drag" a value of 1 when pressed (refer to Fig04 {DragVertex , Page ??). 
  7. If drag has a value of 1, the script in this frame is called from the main looping script ( frame4)ItΓÇÖs important to note that all the scripts up to this point have dealt with setting static point coordinates for the vertices that makes up the 3D object (frame 2), and that the rotation values (Variable: "Yangle" and Variable: "Xangle") set in frame 6 ("Mousetracking") is used to rotate the "world" in frame 7("3d Calc") and not the actual "object".  What weΓÇÖre actually doing is orbiting the ΓÇÿcameraΓÇÖ around the ΓÇÿ[worldΓÇÖsΓÇÖ center point rather than rotating the ΓÇÿobjectΓÇÖ. The ΓÇÿobjectΓÇÖ has a relationship to the ΓÇÿworldΓÇÖ that is set through its individual point coordinates. To move the object or its individual vertices around in the world we need additional calculations to set new values for its x, y and z co-ordinates (the ones initially set in frame 2).
  8.  
  9. Also note that the basic 3D engine has already been covered in frame 7 and that frames 8 and 9 deal with the added feature of changing coordinates of the individual points on the fly. In fact, if you delete frame 8 and 9 all together youΓÇÖll still be left with a fully functional 3D engine, which allows you to set the initial coordinates in frame 2 and still be able to rotate the view.
  10. IΓÇÖve included the last two frames to illustrate a method of moving the points around within their ΓÇÿworldΓÇÖ, which opens up possibilities for numerous applications. IΓÇÖll touch on these a little further down.In my example, I wanted to play with the idea of a mini-3D application that would allow the user to drag points around in an editing view to create his/her own 3D forms (albeit very simple). This application is so specific that I doubt whether you would want to duplicate it. For this reason IΓÇÖm going to move through this quite quickly, focusing on the general concept.  IΓÇÖll extract a few key points towards the end of this chapter.
  11.  
  12. The movie starts with the object being viewed along the Z-axis and the editing view also showing the same view.  The view in the 3d window is set through the combined rotation angles on the X and Y axis ( Variable:Xangle and Variable:Yangle ). If we recap, these angles were set by the position of "/TrailerObj"  (frame 6) which in turn, gets its position from "/Mouseloc".  In frame 3 we set the X and Y coordinate of "/Mouseloc" to 0. In other words, when the movie starts, the rotation value of both variables: "Xangle" and "Yangle" will be 0 which is the view along the Z axis.
  13. To change the view when one of the X,Y or Z buttons are pressed, I simply set the X and Y position of "/Mouseloc", which usually represent the mouse position, to a new coordinate and "/TrailerObj" follows setting new values for Variables: Xangle and Yangle. The coordinates of "/Mouseloc" for the 3 views are as follows:
  14.  
  15. Along X- axis: "/mouseloc" X position = 90 and  "/mouseloc" Y position = 0
  16. Along Y- axis: "/mouseloc" X position = 0 and  "/mouseloc" Y position = 90
  17. Along Z- axis: "/mouseloc" X position = 0 and  "/mouseloc" Y position = 0
  18.  
  19. The appropriate position for "/Mouseloc" is set as part of the action on each one of the X,Y anf Z buttons in the top right-hand corner. 
  20. So, now that we know how to rotate the view to the appropriate angle, the following rules apply:
  21.  
  22. When editing along the Z-axis: the Horizontal (X) and Vertical (Y) distance of  "/dragpoint" away from the center point of the editing view, would correspond to the distance of the X and Y coordinates of "/Vertex" away from the centre point of the world.
  23.  
  24. When editing along the X-axis: the Horizontal (X) and Vertical (Y) distance of  "/dragpoint" away from the center point of the editing view, would correspond to the distance of the Z and Y coordinates of "/Vertex" away from the centre point of the world.
  25.  
  26. When editing along the Y-axis: the Horizontal (X) and Vertical (Y) distance of  "/dragpoint" away from the centrepoint of the editing view, would correspond to the distance of the Z and X coordinates of "/Vertex" away from the centre point of the world.
  27. The X, Y and Z buttons each contains a script that looks like this:
  28.  
  29. On (Press)
  30.       Set Variable: "axisx" = "z"
  31.       Set Variable: "axisy" = "y"
  32.       Set Variable: "Yaxisneg" = 1
  33.       Set Property ("mouseloc", X Position) = 90
  34.       Set Property ("mouseloc", Y Position) = 0
  35.       Begin Tell Target ("xyz")
  36.             Go to and Stop ("x")
  37.       End Tell Target
  38.       Call ("Refresh Editing View")
  39. End On
  40. When the user presses one of these buttons, Variable: "AxisY" is set to a value either "x", "y" or "z". This tells the movie which axis of "/Vertex" should be affected when manipulating the Y position of "/dragpoint" for each view.  It also sets Variable: "AxisX", which does the same except that it tells the movie which axis to affect on manipulating the X position of "/dragpoint". It also sets Variable: "Yposneg" to ΓÇö1 if the Y-Axis is selected.  This simply mirrors the view when editing on the Y-Axis ( without this the editing view along the Y-Axis would appear upside down). It also gives "/Mouseloc" a new position, as already explained above. This rotates view to the new view.
  41. The script in frame 8 looks like this:
  42.  
  43. Set Variable: "dc" = 0
  44. Loop While (dc < 9)
  45.       Set Variable: "dc " = dc + 1
  46.       Set Variable: AxisY&dc = (getproperty("DragVertex"&dc,_Y)-EditingCenterY)*Yaxisneg
  47.       Set Variable: AxisX&dc = getproperty("DragVertex"&dc,_X)-EditingCenterX
  48.  
  49. The script is looped nine times (once for each point). If the "Z button" was the last one to be pressed, you will be editing along the Z-axis, according to our rule mentioned above, Variable: "axisY" will have the value of "y" and Variable: "AxisX" will have "x" as its value. Variable: "EditingCenterY" and "EditingCenterX" represents the coordinates of the centre of the editing view.
  50. After the script has looped nine times:
  51.  
  52. Variable: "y1" will be set to the distance "/dragpoint1" is away from the centre of the editing view on the Y-axis.
  53. Variable: "x1" will be set to the distance "/dragpoint1" is away from the centre of the editing view on the X-axis.
  54.  
  55. Variable: "y2" will be set to the distance "/dragpoint2" is away from the centre of the editing view on the Y-axis.
  56. Variable: "x2" will be set to the distance "/dragpoint2" is away from the centre of the editing view on the X-axis.etc
  57.  
  58. The rest of the script on this frame is simply responsible for updating the lines that connect "/dragpoint1" to "/dragpoint9". This script is similar to the one used in frame 7 to scale the lines between the individual vertices in the 3D object.
  59. Frame 9: (label: Refresh Editing View) Refreshing the Editing View
  60.  
  61. The script contained in this frame refreshes the editing view that the user sees when they press one of the XYZ buttons and is called from the script within these buttons.
  62.